<?php

// $xml = simplexml_load_file("list_address.xml");
//$obj_xml = new DOMDocument();
$obj_xml = simplexml_load_file("list_address.xml");

// echo $obj_xml->getName(); exit(); // address
// print_r($obj_xml); exit();
// echo $obj_xml->count(); exit(); // so luong item co trong xml

// echo $obj_xml->item[0]->pho; exit(); //

// echo count($obj_xml->children()); exit(); // cac node con co bao nhieu nut


// print_r($address);

echo "<ul>";
for($i = 0; $i < $obj_xml->count(); $i++)
{
    echo "<li>".$obj_xml->item[$i]->tinh."</li>";
    echo "<li>".$obj_xml->item[$i]->pho."</li>";
    echo "<li>".$obj_xml->item[$i]->sonha."</li>";
    echo "<br>";
}
echo "</ul>";




/*
// working with DOM
$obj_xml = new DOMDocument();
$obj_xml->load("list_address.xml");

// lay item 1 ra khoi

$node = $obj_xml->getElementsByTagName("item");

foreach($node as $item)
{
    if($item->getAttribute("id") == 1)
        echo $item->nodeValue;
}*/